#include "comm.hpp"

int main()
{
    int fd = open(FIFO_FILE, O_WRONLY);
    if(fd < 0)
    {
        std::cerr << "open fifo error" << '\n';
    }
    std::cout << "open fifo success" << '\n';

    //写入操作
    std::string message;
    int cnt = 1;
    pid_t id = getpid();
    while(true)
    {
        std::cout << "Please Enter# ";
        std::getline(std::cin, message);
        message += ", message number: " + std::to_string(cnt++) + ", " + std::to_string(id);
        int n = write(fd, message.c_str(), message.size());
    }

    close(fd);
    return 0;
}